home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
linux
/
slsv1aa3.zip
/
FONTPAK.TPZ
/
FONTPAK.tar
/
usr
/
src
/
fontpak
/
console.dif
next >
Wrap
Text File
|
1993-02-27
|
11KB
|
397 lines
*** console.c.sav Sat Feb 27 17:12:44 1993
--- console.c Sat Feb 27 17:25:13 1993
***************
*** 1,3 ****
--- 1,4 ----
+ #define CODEPAGE
/*
* linux/kernel/console.c
*
***************
*** 67,72 ****
--- 68,90 ----
static char sel_buffer[SEL_BUFFER_SIZE] = { '\0' };
#endif /* SELECTION */
+ #ifdef DEBUG
+ void console_print(const char * b);
+ #endif
+ #ifdef CODEPAGE
+ void save_font_zero( void );
+ int vc_activate_cp( int currcons, int whichcp );
+ static unsigned long charmap_mem_base; /* base of vga character map memory */
+ static unsigned short sequencer_port_reg;
+ static unsigned short sequencer_port_val;
+ static unsigned short graphics_port_reg;
+ static unsigned short graphics_port_val;
+ static int can_do_cp = 0;
+ static int cp;
+ static int cp_i;
+ static int cp_count;
+ #endif
+
#define NPAR 16
extern void vt_init(void);
***************
*** 114,119 ****
--- 132,140 ----
/* attribute flags */
unsigned long vc_intensity : 2; /* 0=half-bright, 1=normal, 2=bold */
unsigned long vc_underline : 1;
+ #ifdef CODEPAGE
+ int vc_codepage; /* offset into internal codepage info */
+ #endif
unsigned long vc_blink : 1;
unsigned long vc_reverse : 1;
unsigned long vc_s_intensity : 2; /* saved rendition */
***************
*** 133,138 ****
--- 154,165 ----
/* additional information is in vt_kern.h */
} vc_cons [NR_CONSOLES];
+ #ifdef CODEPAGE
+ #define CP_BUFFER_SIZE (256*32)
+ #define MAX_CPs 3
+ char cp_buffers[ MAX_CPs * CP_BUFFER_SIZE ];
+ #endif
+
#define MEM_BUFFER_SIZE (2*80*50*8)
unsigned short *vc_scrbuf[NR_CONSOLES];
***************
*** 175,180 ****
--- 202,211 ----
#define charset (vc_cons[currcons].vc_charset)
#define s_charset (vc_cons[currcons].vc_s_charset)
#define intensity (vc_cons[currcons].vc_intensity)
+ #ifdef CODEPAGE
+ #define codepage (vc_cons[currcons].vc_codepage)
+ #endif
+
#define underline (vc_cons[currcons].vc_underline)
#define blink (vc_cons[currcons].vc_blink)
#define reverse (vc_cons[currcons].vc_reverse)
***************
*** 858,868 ****
need_wrap = 0;
}
enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
! EShash, ESsetG0, ESsetG1, ESignore };
static void reset_terminal(int currcons, int do_clear)
{
top = 0;
bottom = video_num_lines;
state = ESnormal;
--- 889,908 ----
need_wrap = 0;
}
+ #ifndef CODEPAGE
+ enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
+ EShash, ESsetG0, ESsetG1, ESignore};
+ #else
enum { ESnormal, ESesc, ESsquare, ESgetpars, ESgotpars, ESfunckey,
! EShash, ESsetG0, ESsetG1, ESignore, EScodepage0, EScodepage1,
! EScpPROG, EScpPROG1, EScpPROG2, EScpUSE };
! #endif
static void reset_terminal(int currcons, int do_clear)
{
+ #ifdef CODEPAGE
+ codepage = 0;
+ #endif
top = 0;
bottom = video_num_lines;
state = ESnormal;
***************
*** 930,936 ****
--- 970,981 ----
}
if (decim)
insert_char(currcons);
+ #ifdef CODEPAGE
+ if( !codepage )
+ c=translate[ c ];
+ #else
c = translate[c];
+ #endif
*(char *) pos = c;
*(char *) (pos+1) = attr;
if (x == video_num_columns - 1)
***************
*** 994,999 ****
--- 1039,1049 ----
case ESesc:
state = ESnormal;
switch (c) {
+ #ifdef CODEPAGE
+ case 'F': /* We have ESC-F. Codepage stuff! */
+ state = EScodepage0;
+ continue;
+ #endif
case '[':
state = ESsquare;
continue;
***************
*** 1209,1214 ****
--- 1259,1265 ----
G1_charset = GRAF_TRANS;
else if (c == 'B')
G1_charset = NORM_TRANS;
+
else if (c == 'U')
G1_charset = NULL_TRANS;
if (charset == 1)
***************
*** 1215,1220 ****
--- 1266,1354 ----
translate = G1_charset;
state = ESnormal;
continue;
+ #ifdef CODEPAGE
+ case EScodepage0: /* we have ESC-ESC-ESC */
+ switch( c )
+ {
+ case 'P':
+ state = EScpPROG;
+ continue;
+
+ case 'U':
+ state = EScpUSE;
+ continue;
+
+ default:
+ state = ESnormal;
+ }
+ continue;
+
+ case EScpPROG:
+ /* We Now have ESC-F-P. The next byte is the codepage that
+ needs to be programmed */
+ cp = c - '0'; /* let us use ascii number */
+ if( cp > 0 && cp < MAX_CPs )
+ {
+ /*********************************************
+ We now have ESC-F-P-<NUMBER>, where number is
+ the ascii for a valid codepage number. The next
+ 8192*2 characters are assumed to be codepage
+ data bytes, expressed in hexadecimal.
+ **********************************************/
+ state = EScpPROG1;
+ /* point to eh beginning of the current buf */
+ cp_i = cp * CP_BUFFER_SIZE;
+ cp_count = 0;
+ }
+ else state = ESnormal;
+ continue;
+
+ case EScpPROG1:
+ /*****************************************************
+ We are receiving data bytes. To keep things ASCII,
+ there are two characters for each byte of binary data.
+ This is the case for the bytes ( first, third, fifth,
+ etc ), and ESCcpPROG2 is the for the even bytes
+ ( second, fourth, etc ). Of course, the
+ writes to the font buffer take place on the EVEN bytes.
+ *****************************************************/
+ c -= '0';/* ascii hexadecimal to binary conversion */
+ if( c>9 ) c-=7;
+ cp_buffers[ cp_i ] = c;
+ state = EScpPROG2;
+ continue;
+
+
+ case EScpPROG2:
+ /******************************************************
+ This state is for the even-# codepage data bytes.....
+ ******************************************************/
+ c -= '0';
+ if( c>9 ) c-=7;
+ cp_buffers[ cp_i ] *= 0x10; /* move the odd data up */
+ /* move the new ( even ) data into the lower nybble */
+ cp_buffers[ cp_i++ ] += c;
+ if( ++cp_count == CP_BUFFER_SIZE )
+ {
+ state = ESnormal;
+ }
+ else state = EScpPROG1;
+ continue;
+
+ case EScpUSE:
+ /*****************************************************
+ We now have ESC-F-U. We still need to know which
+ codepage we are to use. Choice is zero to MAX_CPs - 1
+ ******************************************************/
+ cp = c - '0';
+ if( cp < MAX_CPs )
+ {
+ vc_activate_cp( currcons, cp );
+ }
+ state = ESnormal;
+ continue;
+
+ #endif /* CODEPAGE? */
default:
state = ESnormal;
}
***************
*** 1310,1315 ****
--- 1444,1459 ----
video_type = VIDEO_TYPE_EGAC;
video_mem_term = 0xc0000;
display_desc = "EGA+";
+ #ifdef CODEPAGE
+ can_do_cp = 1;
+ charmap_mem_base = 0xa0000;
+
+ sequencer_port_reg = 0x3c4;
+ sequencer_port_val = 0x3c5;
+ graphics_port_reg = 0x3ce;
+ graphics_port_val = 0x3cf;
+ save_font_zero();
+ #endif
}
else
{
***************
*** 1351,1356 ****
--- 1495,1503 ----
gotoxy(currcons,orig_x,orig_y);
update_screen(fg_console);
printable = 1;
+ #ifdef CODEPAGE
+ if( can_do_cp ) codepage=0;
+ #endif
printk("Console: %s %s %dx%d, %d virtual consoles\n",
can_do_color?"colour":"mono",
display_desc,
***************
*** 1424,1429 ****
--- 1571,1579 ----
fg_console = new_console;
set_scrmem(fg_console);
set_origin(fg_console);
+ #ifdef CODEPAGE
+ vc_activate_cp( new_console, vc_cons[new_console].vc_codepage );
+ #endif
set_cursor(new_console);
set_leds();
lock = 0;
***************
*** 1519,1524 ****
--- 1669,1778 ----
return -ENODEV;
return 0;
}
+
+ #ifdef CODEPAGE
+
+ /*
+ * Program EGA sequencer and graphics controller to access downloadable
+ * font region. From _Video Systems_, p. 307.
+ */
+
+ void setsf( void )
+ {
+ cli();
+ outb_p( 0x00, sequencer_port_reg ); /* First, the sequencer */
+ outb_p( 0x01, sequencer_port_val ); /* Synchronous reset */
+ outb_p( 0x02, sequencer_port_reg );
+ outb_p( 0x04, sequencer_port_val ); /* CPU writes only to map 2 */
+ outb_p( 0x04, sequencer_port_reg );
+ outb_p( 0x07, sequencer_port_val ); /* Sequential addressing */
+ outb_p( 0x00, sequencer_port_reg );
+ outb_p( 0x03, sequencer_port_val ); /* Clear synchronous reset */
+
+ outb_p( 0x04, graphics_port_reg ); /* Now, the graphics controller */
+ outb_p( 0x02, graphics_port_val ); /* select map 2 */
+ outb_p( 0x05, graphics_port_reg );
+ outb_p( 0x00, graphics_port_val ); /* disable odd-even addressing */
+ outb_p( 0x06, graphics_port_reg );
+ outb_p( 0x00, graphics_port_val ); /* map start at A000:0000 */
+ sti();
+ }
+
+
+ /*
+ * Program EGA back the way it was, for ordinary text operations.
+ * (If the screen was in graphics mode we're up a creek.)
+ * From _Video Systems_, p. 307.
+ */
+
+ void unsetsf( void )
+ {
+ cli();
+ outb_p( 0x00, sequencer_port_reg ); /* Frist, the sequencer */
+ outb_p( 0x01, sequencer_port_val ); /* Synchronous reset */
+ outb_p( 0x02, sequencer_port_reg );
+ outb_p( 0x03, sequencer_port_val ); /* CPU writes to maps 0 and 1 */
+ outb_p( 0x04, sequencer_port_reg );
+ outb_p( 0x03, sequencer_port_val ); /* odd-even addressing */
+ outb_p( 0x00, sequencer_port_reg );
+ outb_p( 0x03, sequencer_port_val ); /* clear synchronous reset */
+
+ outb_p( 0x04, graphics_port_reg ); /* Now, the graphics controller */
+ outb_p( 0x00, graphics_port_val ); /* select map 0 for CPU */
+ outb_p( 0x05, graphics_port_reg );
+ outb_p( 0x10, graphics_port_val ); /* enable even-odd addressing */
+ outb_p( 0x06, graphics_port_reg );
+ outb_p( 0x0e, graphics_port_val ); /* map starts at b800:0000 */
+ sti();
+ }
+
+
+ /*************************************
+ int vc_progcp( int whichcp, char *data )
+ {
+ unsigned long tmp = cp_buffers;
+ tmp += (whichcp*256*32);
+ if(( whichcp < MAX_CPs) && (whichcp > 0))
+ {
+ memcpy((void *) tmp,(void *)data,256*32);
+ return(0);
+ }
+ else return (-EINVAL);
+ }
+ ******************************************/
+
+ void load_cp( int whichcp )
+ {
+ void *tmp_p = cp_buffers;
+
+ tmp_p += ( whichcp * 256 * 32 );
+ setsf(); /* enable EGA access */
+ memcpy( (void *) charmap_mem_base, tmp_p, 256*32 ); /* do it */
+ unsetsf(); /*disable EGA access*/
+ }
+
+ int vc_activate_cp( int currcons, int whichcp )
+ {
+ if(( whichcp < MAX_CPs ) && ( currcons < NR_CONSOLES ))
+ {
+ codepage = whichcp;
+ if( currcons == fg_console ) load_cp( whichcp );
+ return (0);
+ }
+ else return (-EINVAL);
+ }
+
+
+ void save_font_zero( void )
+ {
+ if( can_do_cp )
+ {
+ setsf();
+ memcpy((void *)cp_buffers, (void *) charmap_mem_base, ( 256*32 ));
+ unsetsf();
+ }
+ }
+ #endif /* CODEPAGE? */
#ifdef SELECTION
/* set reverse video on characters s-e of console with selection. */